package com.orhon.smartcampus.modules.systemctl.fetcher;

import com.orhon.smartcampus.modules.systemctl.dao.VersionManagementDao;
import com.orhon.smartcampus.modules.systemctl.entity.*;
import com.orhon.smartcampus.modules.systemctl.gqlModel.*;
import com.orhon.smartcampus.modules.systemctl.mm.*;
import graphql.schema.DataFetcher;
import graphql.schema.DataFetchingEnvironment;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;


@Component
public class VersionManagementFetcher implements DataFetcher {

	@Autowired
	VersionManagementDao versionManagementDao;

	@Override
	public Object get(DataFetchingEnvironment env) throws Exception {
		int id = Integer.parseInt(env.getArgument("id").toString());

		String hql = "from VersionManagement where deleteAt = null and id = "+id;
		VersionManagement item =  versionManagementDao.findId(hql, null);
		if(item!=null) {
			GQLVersionManagement gqlVersionManagement = VersionManagementMapper.MAPPER.toVersionManagement(item);
			return gqlVersionManagement;
		}
		return null;

	}


}
